<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!-- header -->
<jsp:include   page="common/header.jsp" flush="true">
    <jsp:param name="title" value="文书管理" /> 
</jsp:include>
<!-- 左侧 -->
<jsp:include   page="common/left.jsp" flush="true"/>

 <!-- 右侧 -->
<div class="audit-page">
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-12">
                <div class="panel">
                    <div class="panel-heading">
                        <div class="row">
                            <span class="audit-heading-icon"></span><span class="text">文书管理</span>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="panel-body-title">
                            <a href="javascript:;" class="writ-title-finish writ-title-item active" data-status="1">已完成</a>
                            <a href="javascript:;" class="writ-title-wait writ-title-item" data-status="-1">审核中</a>
                            <a href="javascript:;" class="writ-title-pass writ-title-item" data-status="2">未通过</a>
                        </div>
                        <div class="panel-body-content">
                            <div class="panel-body-item1 panel-body-item">
                                <div class="row">
                                    <div class="col-lg-12">
                                        <div class="table-responsive">
                                                <table class="table table-bordered table-hover datalisttable">
                                                    <thead>
                                                        <tr>
                                                            <th>名称</th>
                                                            <th>发送人</th>
                                                            <th>时间</th>
                                                            <th>是否羁押</th>
                                                            <th>操作</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        
                                                    </tbody>
                                                </table>
                                                <div class="page">
                                                        <div class="left fl">
                                                            <span class="pagestr">
                                                            <a href="javascript:;">首页</a>
                                                            <a href="javascript:;">上一页</a>
                                                            <a href="javascript:;" class="active">1</a>
                                                            <a href="javascript:;">2</a>
                                                            <a href="javascript:;">下一页</a>
                                                            <a href="javascript:;">尾页</a>
                                                            </span>
                                                            <span>跳至</span>
                                                            <input type="text" id="gotopage" />
                                                            <a href="javascript:;" class="gobtn">GO</a>
                                                        </div>
                                                        <div class="right fr">
                                                            <span class="now-num">当前第<b class="curpage">1</b>页</span>
                                                            <span class="toggle-num">共<b class="totalpage">1</b>页</span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 浮层 -->
        <div class="audit-msk none">
            <div class="audit-msk-dialog">
                <div class="audit-dialog-title">
                    <span class="fl">审核</span>
                    <a href="javascript:;" class="audit-dialog-close fr"></a>
                </div>
                <div class="audit-dialog-content">
                    <div class="audit-dialog-wrapper">
                        <!-- Swiper -->
                        <div class="swiper-container">
                            <div class="swiper-wrapper">
                                <div class="swiper-slide">
                                    <img src="${basePath }/images/check-file-img1.png" alt="" />
                                </div>
                                <div class="swiper-slide">
                                    <img src="${basePath }/images/check-file-img1.png" alt="" />
                                </div>
                                <div class="swiper-slide">
                                    <img src="${basePath }/images/check-file-img1.png" alt="" />
                                </div>
                                <div class="swiper-slide">
                                    <img src="${basePath }/images/check-file-img1.png" alt="" />
                                </div>
                                <div class="swiper-slide">
                                    <img src="${basePath }/images/check-file-img1.png" alt="" />
                                </div>
                                <div class="swiper-slide">
                                    <img src="${basePath }/images/check-file-img1.png" alt="" />
                                </div>
                            </div>
                            <!-- Add Pagination -->
                            <div class="swiper-pagination"></div>
                        </div>
                    </div>
                    <div class="audit-next-btn"></div>
                    <div class="audit-prev-btn"></div>
                    <div class="audit-dialog-btn">
                        <a href="javascript:;" class="audit-dialog-btn1"></a>
                        <a href="javascript:;" class="audit-dialog-btn2"></a>
                    </div>
                </div>
            </div>
        </div>
        <!-- 不通过原因 -->
        <div class="audit-msk-pass none">
            <div class="audit-pass-dialog">
                <div class="audit-dialog-title">
                    <span class="fl">审核</span>
                    <a href="javascript:;" class="audit-pass-close fr"></a>
                </div>
                <div class="audit-pass-content">
                    <textarea placeholder="请填写审核不通过的原因"></textarea>
                    <div class="audit-pass-btn">
                        <a href="javascript:;" class="audit-pass-btn1"></a>
                        <a href="javascript:;" class="audit-pass-btn2"></a>
                    </div>
                </div>
            </div>
        </div>
    
<!-- 底部 -->
<jsp:include   page="common/bottom.jsp" flush="true"/>
 <script type="text/javascript">
     var canclick=true;
     var adminid=1;
     var curpage=1;
     var status=1;
     var chaxuntmp='<tr><td>@checkname@</td><td>@sendname@</td><td>@createtime@</td><td>@erestr@</td><td>@btnstr@</td></tr>';
     var btnstr='<a href="javascript:;">生成文书</a>';
        $('.writ-title-item').click(function() {//待审核已审核切换
            $(this).addClass('active').siblings().removeClass('active');
            status=$(this).attr("data-status");
            if(canclick){
                canclick=false;
                curpage=1;
                
                getdatalist();
            }
        })
        function getdatalist(){
            $(".datalisttable tbody").empty();
            $.ajax({
                type : "POST",
                url : "${basePath }/wxChecklistAction_jsonlist",
                data : {"status":status,"toadminid":adminid,"currentPage":curpage},
                dataType: "json",
                success : function(data) {
                    if(data.success=="success"){
                        genpagestr(data.currentPage,data.totalpage);
                        if(data.data!=null&&data.data!="null"){
                            appendchecklist(data.data);
                        }
                        if(data.currentPage<data.totalpage){
                            curpage++;
                        } 
                        canclick=true;
                    }
                }
            });
        }

        function genpagestr(currentPage,totalpage){
          var pagestr='<a href="javascript:;" data-page="1" class="pagebtn">首页</a>';
          if(currentPage>1){
              pagestr=pagestr+'<a href="javascript:;" data-page="'+(currentPage-1)+'" class="pagebtn">上一页</a>';
          }
          for(var i=1;i<=totalpage;i++){
              if(currentPage==i){
                  pagestr=pagestr+'<a href="javascript:;" data-page="'+i+'" class="pagebtn active">'+i+'</a>';
              }else{
                  pagestr=pagestr+'<a href="javascript:;" data-page="'+i+'" class="pagebtn">'+i+'</a>';
              }
          }
          if(currentPage<totalpage){
              pagestr=pagestr+'<a href="javascript:;" data-page="'+(currentPage+1)+'" class="pagebtn">下一页</a>';
          }
          pagestr=pagestr+'<a href="javascript:;" data-page="'+totalpage+'" class="pagebtn">尾页</a>';
          $(".pagestr").html(pagestr);
        }
        function appendchecklist(data){
            var appendstr="";
            $.each(data,function(i,item){
                appendstr=chaxuntmp;
                for(var vk in item){ 
                    eval("var re = /@" + vk + "@/g;"); 
                    appendstr=appendstr.replace(re,item[vk]);
                }
                if(status==1){
                    var url="${basePath }/fileLoadAction_downLoadShenpi?detailId=";
                    url=url+item.udetailid;
                    appendstr=appendstr.replace("@btnstr@",'<a href="'+url+'">生成文书</a>');
                }else if(status==-1){
                    appendstr=appendstr.replace("@btnstr@","审核中");
                }else if(status==2){
                    appendstr=appendstr.replace("@btnstr@","未通过");
                }
                $(".datalisttable tbody").append(appendstr);
            })
        }
        var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
            paginationType: 'fraction',
            observer:true,
            observeParents:true
        });
        $('.audit-next-btn').click(function() {
            swiper.slideNext();
        })
        $('.audit-prev-btn').click(function() {
            swiper.slidePrev();
        })
        $(document).on('click', '.audit-shenpi-btn', function() {
            $('.audit-msk').fadeIn(400);
            swiper.slideTo(0,10);
        })
        $(document).on('click', '.audit-dialog-close', function() {
            $('.audit-msk').fadeOut(400);
        })
        $(document).on('click', '.audit-dialog-btn1', function() {
            $('.audit-msk').fadeOut(400);
            
        })
        $(document).on('click', '.audit-dialog-btn2', function() {
            $('.audit-msk').fadeOut(400);
            $('.audit-msk-pass').fadeIn(400);
        })
        $(document).on('click', '.audit-pass-close', function() {
            $('.audit-msk-pass').fadeOut(400);
        })
        $(document).on('click', '.audit-pass-btn2', function() {
            $('.audit-msk-pass').fadeOut(400);
        })
        $(document).on('click', '.pagebtn', function() {
            if(canclick){
                canclick=false;
                curpage=$(this).attr("data-page");
//                $(".datalisttable tbody").empty();
                getdatalist();
            }
        })
        

        getdatalist();
    </script>